# Description ------------------------------------------------------------------
#   This R script runs the individual R scripts that build the datasets and
#   run the analyses. See individual scripts for more information.
#
#   The order:
#     1.  buildPanelPGE.R
#     2. buildPanelSoCal.R
#     3a. buildPanelCommonZips.R
#     3b. buildPanelAllZips.R
#     4a. analyzeCommon.R
#     4b. analyzeAllZips.R

# 1. Build the PG&E panels ------------------------------------------------------
  # Change directory to R scripts
  setwd("S:/Edward/Elasticity/CodeR")
  # Run the PG&E script
  source("buildPanelPGE.R")
  # Clean up
  rm(list = ls())
  gc()

# 2. Build the SoCal panels -----------------------------------------------------
  # Change directory to R scripts
  setwd("S:/Edward/Elasticity/CodeR")
  # Run the SoCal script
  source("buildPanelSoCal.R")
  # Clean up
  rm(list = ls())
  gc()

# 3a. Build the common zips/cities panel ----------------------------------------
  # Change directory to R scripts
  setwd("S:/Edward/Elasticity/CodeR")
  # Run the script
  source("buildPanelCommonZips.R")
  # Clean up
  rm(list = ls())
  gc()

# 3b. Build sample of all zips --------------------------------------------------
  # Change directory to R scripts
  setwd("S:/Edward/Elasticity/CodeR")
  # Run the analysis script
  source("buildPanelAllZips.R")
  # Clean up
  rm(list = ls())
  gc()

# 4a. Analysis on common zips ---------------------------------------------------
  # Change directory to R scripts
  setwd("S:/Edward/Elasticity/CodeR")
  # Run the analysis script
  source("analyzeCommon.R")
  # Clean up
  rm(list = ls())
  gc()

# 4b. Analysis on sub sample of all zips ----------------------------------------
  # Change directory to R scripts
  setwd("S:/Edward/Elasticity/CodeR")
  # Run the analysis script
  source("analyzeAllZips.R")
  # Clean up
  rm(list = ls())
  gc()
